
public class test {
    //实现两个数的交换
    public static void swap(MyValue myVal,MyValue myVal1){
        int tmp = myVal.val;
        myVal.val = myVal1.val;
        myVal1.val = tmp;
    }
    public static void main(String[] args) {
        MyValue myValue = new MyValue();
        MyValue myValue1 = new MyValue();
        myValue.val = 10;
        myValue1.val = 20;
        System.out.println("交换前"+myValue.val+" "+myValue1.val);
        swap(myValue,myValue1);
        System.out.println("交换后"+myValue.val+" "+myValue1.val);
    }
    public static void main2(String[] args) {
        MyDate d1 = new MyDate();
        MyDate d2 = new MyDate();
        MyDate d3 = new MyDate();
       /* d1.year = 2025;
        d1.month = 5;
        d1.day = 29;*/
        d1.setDay(2025,5,29);
        d2.setDay(2025,6,25);
        d3.setDay(2025,7,25);
        d1.printDay();
        d2.printDay();
        d3.printDay();
    }
    //类的实例化
    public static void main1(String[] args) {
        Dog dog1 = new Dog();  //成员变量如何被调用；
        dog1.name = "大黄";
        Dog dog2 = new Dog();
        dog2.name = "旺财";
        dog2.age = 5;
        Dog dog3 = new Dog(); //通过new关键字实例化多个对象
        dog3.sort = "拉布拉多";
        System.out.println(dog1.name);//输出
        System.out.println(dog2.name);//每次new对象都会产生一个新的对象
        dog1.sleep();   //成员方法如何被调用；
        dog1.bark();
        dog1.wag();
        dog2.wag();
        dog2.sleep();
        dog2.bark();
    }
}
